package person.bing.fbcloud.filter;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

/**
 * @author: mengfanbing
 * @date: 2019/7/30
 * 路由限流配置
 */
@Configuration
public class RateLimiter {
    @Bean(value = "remoteAddKeyResolver")
    public KeyResolver remoteAddKeyResolver(){
        return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress());
    }
}
